package com.ts.animal.domain;

import com.alibaba.fastjson.JSON;
import com.ts.common.utils.StringUtils;

/**
 * 预警配置 扩展
 *
 * @author bobby
 * @email bobby@126.com
 * @date 2022-09-02 16:18:40
 */
public class ExWarningSetDO extends WarningSetDO {

    private WarningSet WarningSet;

    public static ExWarningSetDO getExWarningSetDO(WarningSetDO warningSetDO) {
        String warningSetDOString = JSON.toJSONString(warningSetDO);
        ExWarningSetDO exWarningSetDO = JSON.parseObject(warningSetDOString, ExWarningSetDO.class);
        return exWarningSetDO;
    }

    @Override
    public void setWarningJsonSetData(String warningJsonSetData) {
        super.setWarningJsonSetData(warningJsonSetData);
        WarningSet warningSet = JSON.parseObject(warningJsonSetData, WarningSet.class);
        if (this.getWarningSet() == null) {
            this.setWarningSet(warningSet);
        }
    }

    public ExWarningSetDO.WarningSet getWarningSet() {
        return WarningSet;
    }

    public void setWarningSet(ExWarningSetDO.WarningSet warningSet) {
        WarningSet = warningSet;
        if (StringUtils.isEmpty(this.getWarningJsonSetData())) {
            String warningSetString = JSON.toJSONString(warningSet);
            this.setWarningJsonSetData(warningSetString);
        }
    }

    //预警设置
    public static class WarningSet {
        //疾病
        private Sick sick;
        //发情
        private Oestrus oestrus;
        //发情
        private Parturition parturition;
        //基站
        private Station station;
        //耳标
        private Tag tag;


        public Sick getSick() {
            return sick;
        }

        public void setSick(Sick sick) {
            this.sick = sick;
        }

        public Oestrus getOestrus() {
            return oestrus;
        }

        public void setOestrus(Oestrus oestrus) {
            this.oestrus = oestrus;
        }

        public Parturition getParturition() {
            return parturition;
        }

        public void setParturition(Parturition parturition) {
            this.parturition = parturition;
        }

        public Station getStation() {
            return station;
        }

        public void setStation(Station station) {
            this.station = station;
        }

        public Tag getTag() {
            return tag;
        }

        public void setTag(Tag tag) {
            this.tag = tag;
        }
    }

    //疾病 预警设置
    public static class Sick {
        //体温小于
        Float lowerBodyTemperature;
        //体温大于
        Float upperBodyTemperature;

        public Float getLowerBodyTemperature() {
            return lowerBodyTemperature;
        }

        public void setLowerBodyTemperature(Float lowerBodyTemperature) {
            this.lowerBodyTemperature = lowerBodyTemperature;
        }

        public Float getUpperBodyTemperature() {
            return upperBodyTemperature;
        }

        public void setUpperBodyTemperature(Float upperBodyTemperature) {
            this.upperBodyTemperature = upperBodyTemperature;
        }
    }

    //发情 预警设置
    public static class Oestrus {
        //距离生日最小天数 开始预警
        Integer startBirthday;
        //距离生日最小天数 接收预警
        Integer endBirthday;

        public Integer getStartBirthday() {
            return startBirthday;
        }

        public void setStartBirthday(Integer startBirthday) {
            this.startBirthday = startBirthday;
        }

        public Integer getEndBirthday() {
            return endBirthday;
        }

        public void setEndBirthday(Integer endBirthday) {
            this.endBirthday = endBirthday;
        }

    }

    //分娩 预警设置
    public static class Parturition {
        //距离配种日期最小天数 开始预警
        Integer startHybridizationDay;
        //距离配种日期最小天数 接收预警
        Integer endHybridizationDay;
        //体温大于体温
        Float upperBodyTemperature;

        public Integer getStartHybridizationDay() {
            return startHybridizationDay;
        }

        public void setStartHybridizationDay(Integer startHybridizationDay) {
            this.startHybridizationDay = startHybridizationDay;
        }

        public Integer getEndHybridizationDay() {
            return endHybridizationDay;
        }

        public void setEndHybridizationDay(Integer endHybridizationDay) {
            this.endHybridizationDay = endHybridizationDay;
        }

        public Float getUpperBodyTemperature() {
            return upperBodyTemperature;
        }

        public void setUpperBodyTemperature(Float upperBodyTemperature) {
            this.upperBodyTemperature = upperBodyTemperature;
        }
    }
    //基站告警 设置
    public static class Station {
        //GPS天线状态 持续异常时间
        Float daGpsDuration;
        //GPS天线状态 持续异常次数
        Float daGpsTimes;

        //市电源状态 持续异常时间
        Float daPowerDuration;
        //市电源状态 持续异常次数
        Float daPowerTimes;

        //基站电池电压 持续异常时间
        Float daElecDuration;
        //基站电池电压 持续异常次数
        Float daElecTimes;
        //基站电池电压 最小值
        Float daElecMin;

        //基站数据 未上传时间
        Float upLoadDuration;

        //弹窗开关
        String dialogTipSwitch;

        public Float getDaGpsDuration() {
            return daGpsDuration;
        }

        public void setDaGpsDuration(Float daGpsDuration) {
            this.daGpsDuration = daGpsDuration;
        }

        public Float getDaGpsTimes() {
            return daGpsTimes;
        }

        public void setDaGpsTimes(Float daGpsTimes) {
            this.daGpsTimes = daGpsTimes;
        }

        public Float getDaPowerDuration() {
            return daPowerDuration;
        }

        public void setDaPowerDuration(Float daPowerDuration) {
            this.daPowerDuration = daPowerDuration;
        }

        public Float getDaPowerTimes() {
            return daPowerTimes;
        }

        public void setDaPowerTimes(Float daPowerTimes) {
            this.daPowerTimes = daPowerTimes;
        }

        public Float getDaElecDuration() {
            return daElecDuration;
        }

        public void setDaElecDuration(Float daElecDuration) {
            this.daElecDuration = daElecDuration;
        }

        public Float getDaElecTimes() {
            return daElecTimes;
        }

        public void setDaElecTimes(Float daElecTimes) {
            this.daElecTimes = daElecTimes;
        }

        public Float getDaElecMin() {
            return daElecMin;
        }

        public void setDaElecMin(Float daElecMin) {
            this.daElecMin = daElecMin;
        }

        public Float getUpLoadDuration() {
            return upLoadDuration;
        }

        public void setUpLoadDuration(Float upLoadDuration) {
            this.upLoadDuration = upLoadDuration;
        }

        public String getDialogTipSwitch() {
            return dialogTipSwitch;
        }

        public void setDialogTipSwitch(String dialogTipSwitch) {
            this.dialogTipSwitch = dialogTipSwitch;
        }
    }

    //耳标告警 设置
    public static class Tag {
        //电压 持续异常时间
        Float daElecDuration;
        //电压 持续异常次数
        Float daElecTimes;
        //电压 最小值
        Float daElecMin;

        //耳标数据 未上传时间
        Float upLoadDuration;
        //弹窗开关
        String dialogTipSwitch;

        public Float getDaElecDuration() {
            return daElecDuration;
        }

        public void setDaElecDuration(Float daElecDuration) {
            this.daElecDuration = daElecDuration;
        }

        public Float getDaElecTimes() {
            return daElecTimes;
        }

        public void setDaElecTimes(Float daElecTimes) {
            this.daElecTimes = daElecTimes;
        }

        public Float getDaElecMin() {
            return daElecMin;
        }

        public void setDaElecMin(Float daElecMin) {
            this.daElecMin = daElecMin;
        }

        public Float getUpLoadDuration() {
            return upLoadDuration;
        }

        public void setUpLoadDuration(Float upLoadDuration) {
            this.upLoadDuration = upLoadDuration;
        }

        public String getDialogTipSwitch() {
            return dialogTipSwitch;
        }

        public void setDialogTipSwitch(String dialogTipSwitch) {
            this.dialogTipSwitch = dialogTipSwitch;
        }
    }


    public static void main(String[] args) {
        ExWarningSetDO.WarningSet warningSet = new ExWarningSetDO.WarningSet();

        warningSet.setOestrus(new ExWarningSetDO.Oestrus());
        warningSet.setParturition(new ExWarningSetDO.Parturition());
        warningSet.setSick(new ExWarningSetDO.Sick());
        warningSet.setStation(new ExWarningSetDO.Station());
        warningSet.setTag(new ExWarningSetDO.Tag());

        warningSet.getOestrus().setStartBirthday(40);
        warningSet.getOestrus().setEndBirthday(50);

        warningSet.getParturition().setStartHybridizationDay(20);
        warningSet.getParturition().setEndHybridizationDay(30);
        warningSet.getParturition().setUpperBodyTemperature(37.7f);

        warningSet.getSick().setLowerBodyTemperature(35f);
        warningSet.getSick().setUpperBodyTemperature(38f);

        warningSet.getStation().setDaElecDuration(null);

        String json = JSON.toJSONString(warningSet);
        System.out.println(JSON.toJSONString(warningSet));

        WarningSetDO warningSetDO = new WarningSetDO();
        warningSetDO.setAnimalType("animal");
        warningSetDO.setAnimalVarieties("cattle");
        warningSetDO.setWarningJsonSetData(json);
        System.out.println(JSON.toJSONString(warningSetDO));


        System.out.println(JSON.toJSONString(ExWarningSetDO.getExWarningSetDO(warningSetDO)));

        ExWarningSetDO exWarningSetDO = new ExWarningSetDO();
        exWarningSetDO.setAnimalType("animal");
        exWarningSetDO.setAnimalVarieties("cattle");
        exWarningSetDO.setWarningSet(warningSet);

        System.out.println(JSON.toJSONString(ExWarningSetDO.getExWarningSetDO(warningSetDO)));
    }

}
